Ext.ns("Ext.baiyue");

function welcomeClick(){
	var workframe = document.getElementById("workframe");
	workframe.src = "welcome.jsp";
}
function redirectTo(url){
	var workframe = document.getElementById("workframe");
	workframe.src = url;
}
Ext.baiyue.ConsoleMain = function(config){
	var welometip    = '<a href="" onclick="welcomeClick()">首页</a>';
	var logoHtml   	 = '<div style="background:url('+contants.contextPath+'/images/loginbackground.jpg) no-repeat;height:70px"></div>';
    var centerHtml 	 = '<iframe id="workframe" src="welcome.jsp" width="100%" height="100%" frameborder="no"></iframe>';
	var copyRightHtml= '<div align="center">预留版权图片区域</div>'
    
	Ext.QuickTips.init();
	
	//顶部欢迎区域
	var pnWelcome = new Ext.Panel({
		id 		: 'north',
		region	: 'north',
		html	: logoHtml,
		frame	: true,
		autoHeight: true,
		margins : '0 0 0 0',
		height  : 70,
	});
	//底部版权区域
	var pnCopyright  = new Ext.Panel({
		id		: 'south',
		region	: 'south',
		html	: copyRightHtml,
		margins : '0 0 0 0',
		frame   : true,
		autoHeight : true,
		height	: 30,
	});
	//右边内容区域
	var pnCenter = new Ext.Panel({
		id		: 'center',
		region	: 'center',
		frame   : true,
	    html	: centerHtml,
		autoHeight : true,
		autoWidth  : true,
	});
	//左边导航栏
	var pnNavigation  = new Ext.Panel({
		id		: 'west',
		region	: 'west',
		title	: "管理模块",
		frame   : true,
		margins : '0 0 0 0',
		autoWidth : true,
		width	: contants.navigationWidth,
		buttonAlign: 'center',
	});
	
	//管理员管理按钮
	var btAdmin = new Ext.Button({
		id     : "AdminMng",
		text   : "管理员管理",
		width  : contants.navigationWidth - 20,
		height : contants.navigationButtonHeight,
		icon   : '',
		iconAlign:'bottom',
		allowDepress : false,
		enableToggle : false,
		handler : function() {
			redirectTo("admin/index.do");
			//修改title
			var tip = welometip+">管理者管理";
			pnCenter.setTitle(tip);
		},
	});
	//用户管理按钮
	
	var btUser = new Ext.Button({
		id     : "UserMng",
		text   : "用户管理",
		width	: contants.navigationWidth-20,
		height  : contants.navigationButtonHeight,
		allowDepress: false,
	    enableToggle: false,
		icon    : '',
		iconAlign: 'right',
	    handler : function(){
	    	//
			redirectTo("userMng/index.do");
	    	//修改title
			var tip = welometip+">用户管理";
			pnCenter.setTitle(tip);
	    }
	});
		
	//图书管理按钮
	var btBook = new Ext.Button({
		id      : "BookMng",
		text    : "图书管理",
		width	: contants.navigationWidth-20,
		height  : contants.navigationButtonHeight,
		allowDepress: false,
	    enableToggle: false,
		icon    : '',
		iconAlign: 'right',
	    handler : function(){
	    	//
			redirectTo("bookMng/index.do");
	    	//修改title
			var tip = welometip+">图书管理";
			pnCenter.setTitle(tip);
	    }
	});
	//显示布局
	var vp = new Ext.Viewport({
		layout  : "border",
		border  : false,
		items	: [
		     	   pnWelcome,
		     	   pnCenter,
		     	   pnCopyright,
		     	   pnNavigation
		     	   ],
	});
	
	//添加导航按钮
	pnNavigation.setTitle("当前位置:欢迎您","url("+contants.contextPath+"images/loginbackground.jpg)");
	pnNavigation.add(btAdmin);
	pnNavigation.add(btUser);
	pnNavigation.add(btBook);
	pnNavigation.doLayout();
	//设置title
	pnCenter.setTitle(welometip);
	
}